/* About this program :
 * Problem number : UVa's ACM 00477
 * Author : Ives Liao
 * Submit time's : ?
 * Result : Accepted (2010/Oct./04 12:54 PM)
 *
 */
typedef struct COORDINATE_DEF {
    float x, y;
} COORD;

typedef struct RECTANGLE_DEF {
    COORD up_left, low_right;
} RECTANGLE;

typedef struct CIRCLE_DEF {
    COORD center;
    float radius;
} CIRCLE;

typedef struct FIGURE_DEF {
    RECTANGLE rect;
    CIRCLE cir;
    char flag;
} FIGURE;

#define MAX_FIGURE_NUM 10

#ifdef ONLINE_JUDGE
    #include<stdio.h>
    #include<stdlib.h>
    #include<math.h>
    #define INPUT stdin
    #define TRUE 1
    #define FALSE 0
    int main(){
#else
    #include"header.h"
    #define INPUT fptIn

    int acm_00477() {
        printf("--ACM 477 begin here--\n");
        FILE *fptIn = fopen("Resource/acm_00477.txt", "r");
        if (fptIn == NULL)//Distinguish the input file is load success.
        {
            printf("File acm_00477.txt load fail.\n");
            printf("Program will exit.\n");
            return EXIT_FAILURE;
        }
#endif

    int fig_ctr, point_ctr, in_fig, fig_num;
    float x, y, pow_radius;
    char fig_flag;
    FIGURE fig_range[MAX_FIGURE_NUM];
    fscanf(INPUT, " %c", &fig_flag); /*Get the first flag of data.*/
    fig_num = 0; /*Default the figure number counter.*/
    while (fig_flag != '*') {
        switch (fig_flag) {
            case 'r':/*If the flag is rectangle*/
                fig_range[fig_num].flag = 'r'; /*Set the flag to recognize data's type*/
                fscanf(INPUT, " %f %f", &fig_range[fig_num].rect.up_left.x, &fig_range[fig_num].rect.up_left.y); /*Load rectangle up left point's coord*/
                fscanf(INPUT, " %f %f\n", &fig_range[fig_num].rect.low_right.x, &fig_range[fig_num].rect.low_right.y); /*Load rectangle low right point's coord*/
                fig_num = fig_num + 1; /*Add figure's number counter.*/
                break;
            case 'c':/*If the flag is circle*/
                fig_range[fig_num].flag = 'c'; /*Set the flag to recognize data's type*/
                fscanf(INPUT, " %f %f", &fig_range[fig_num].cir.center.x, &fig_range[fig_num].cir.center.y); /*Load circle center's coord*/
                fscanf(INPUT, " %f\n", &fig_range[fig_num].cir.radius); /*Load circle's radius*/
                fig_num = fig_num + 1; /*Add figure's number counter.*/
                break;
        }
        fscanf(INPUT, " %c", &fig_flag); /*Get the next data's flag*/
    }
    fscanf(INPUT, "%f %f\n", &x, &y); /*Scan the first point.*/
    point_ctr = 1; /*Default the point_counter.*/
    while (((int) (x * 10) != 99999) && ((int) (y * 10) != 99999)) {
        fig_ctr = 0; /*Default rect_counter to 0.*/
        in_fig = FALSE; /*Default in_fig to fail.*/
        while (fig_ctr < fig_num) {/*Run the loop to distinguish all rectangle.*/
            switch (fig_range[fig_ctr].flag) {
                case 'r':
                    /*printf("Process get in the RECTANGLE distinguish\n");*/
                    if (x > fig_range[fig_ctr].rect.up_left.x && y < fig_range[fig_ctr].rect.up_left.y) {
                        if (x < fig_range[fig_ctr].rect.low_right.x && y > fig_range[fig_ctr].rect.low_right.y) {/*Distinguish the point is in the rectangle*/
                            fprintf(stdout, "Point %d is contained in figure %d\n", point_ctr, fig_ctr + 1);
                            in_fig = TRUE; /*Set the flag to TRUE.*/
                        }
                    }
                    break;
                case 'c':
                    /*printf("Process get in the CIRCLE distinguish\n");*/
                    pow_radius = fig_range[fig_ctr].cir.radius * fig_range[fig_ctr].cir.radius;
                    if ((pow(x - fig_range[fig_ctr].cir.center.x, 2) + pow(y - fig_range[fig_ctr].cir.center.y, 2)) < pow_radius) {
                        fprintf(stdout, "Point %d is contained in figure %d\n", point_ctr, fig_ctr + 1);
                        in_fig = TRUE; /*Set the flag to TRUE.*/
                    }
                    break;
            }
            fig_ctr = fig_ctr + 1; /*To next rectangle's data.*/
        }
        if (in_fig == FALSE)/*If not in any rectangle do this.*/
        {
            fprintf(stdout, "Point %d is not contained in any figure\n", point_ctr);
        }
        fscanf(INPUT, "%f %f\n", &x, &y); /*Scan next point.*/
        point_ctr = point_ctr + 1;
    }
    #ifndef ONLINE_JUDGE
        printf("--ACM 477 end here--\n");
        fclose(INPUT); /*Close the input file.*/
    #endif
    return 0;
}
